#ifndef MSGTHREAD_H
#define MSGTHREAD_H

#include <QObject>
#include <QThread>
#include <QTcpSocket>
#include <QDebug>
#include <QFile>
#include <QTimer>
#include <QDataStream>

class MsgThread :public QThread
{
    Q_OBJECT //信号与槽
public:
    explicit MsgThread(QTcpSocket *s, QString token);
    void run(); //虚函数(线性处理函数)
    void msgHander(QString msg);
    QString blogListData(QMap<int, QMap<QString, QString>> map, QString type1, QString type2, QString res);
    QString resListData(QMap<int, QMap<QString, QString>> map, QString type1, QString type2, QString res);
    QString commentListData(QMap<int, QMap<QString, QString>> map, QString type, QString result);
    bool isSend=false;
    QList<QString> sendList;
    QString token;

signals:
    void signalSendMsg(QString);

public slots:
    void slotSendMsg(QString);
    void slotReadMsg();
    void slotMsgTimer();

private:
    QTcpSocket *socket;
    QTimer *timer;

    QString recvMsg;
    qint64 bytesReceived=0;
    qint64 recvTotalBytes=0;

    QByteArray outBlock;
    qint64 sendTotalBytes=0;
    qint64 bytesToWrite=0;

};

#endif // MYTHREAD_H
